package com.ftar.urgent.voice;

import android.util.Log;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;
import java.util.Map;

/**
 * @author: wei.jin
 * @date: 2023/6/26
 * @email: wei.jin@fanttec.com
 * @description：
 */
public class AsrSocket extends WebSocketClient {
    private String TAG = this.getClass().getSimpleName();

//    public AsrSocket(URI serverUri) {
//        super(serverUri, new Draft_6455());
//    }

    public AsrSocket(URI serverUri, Map<String, String> httpHeaders) {
        super(serverUri, new Draft_6455(), httpHeaders);
        Log.i(TAG, String.format("init AsrSocket,url is %s", serverUri.toString()));
    }

    @Override
    public void onOpen(ServerHandshake serverHandshake) {
        Log.i(TAG, "onOpen()");
    }

    @Override
    public void onMessage(String message) {
        Log.i(TAG, "onMessage()");
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
        Log.e(TAG, String.format("onClose(),code is %d,reason is %s, remote is %s", code, reason, remote));
    }

    @Override
    public void onError(Exception ex) {
        Log.e(TAG, "onError()", ex);
    }

}
